//
//  JCNavigationController.swift
//  SinaWeibo_18
//
//  Created by mac on 15/10/11.
//  Copyright © 2015年 cz. All rights reserved.
//

import UIKit

class JCNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        //判断控制器是否多个
        
        if childViewControllers.count > 0 {
            var titleName = "返回"
            
            //显示界面title
            if childViewControllers.count == 1 {
                titleName = (childViewControllers.first?.title)!
            }
            //push时  隐藏底部tabbar
            viewController.hidesBottomBarWhenPushed = true
            //设置leftitem
           viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.item("navigationbar_back_withtext", title: titleName, target: self, action: "back")
            
        }
        super.pushViewController(viewController, animated: true
        )
    }
    @objc private func back(){
        popViewControllerAnimated(true)
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
